/**fdopen*/
#include<errno.h>
#include<stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
int main(){
	int fd;
	int ret;
	fd=open("./test.txt",O_WRONLY | O_CREAT | O_TRUNC, 0666);
	if(-1==fd){
		perror("open error");
		return 1;
	}
	FILE *f=fdopen(fd,"w");
	if(NULL==f){
		perror("fdopen error");
		close(fd);
		return 1;
	}
	ret=fwrite("hello world",1,11,f);
	if(11>ret){
		printf("fwrite error or end-of-file\n");
		fclose(f);
		return 1;
	}
	fclose(f);
	return 0;
}
